import { get, post, put, del } from '@/utils/request'

// 示例 POST 请求
// export function page(query:any) {
//   return request({
//     url: '/dailyPlan/page',
//     method: 'post',
//     data: query
//   })
// }
export const page = async (data:any) => {
  try {
      const response = await post<any>('/dailyPlan/page', data);
      return response;
  } catch (error) {
  }
};

// 示例 GET 请求
// 查询定时任务调度详细
export const getById = async (query?:any) => {
  try {
      const response = await get<any>('/dailyPlan/getById', query);
      return response;
  } catch (error) {
      console.error('GET error:', error);
  }
};


// export function getById(id:number) {
//   return request({
//     url: '/dailyPlan/getById/' + id,
//     method: 'get'
//   })
// }

// 新增定时任务调度
export const add = async (data:any) => {
  try {
      const response = await post<any>('/dailyPlan/add', data);
      return response;
  } catch (error) {
  }
};
// 新增定时任务调度
// export function add(data:any) {
//   return request({
//     url: '/dailyPlan/add',
//     method: 'post',
//     data: data
//   })
// }

// 修改定时任务调度
export const update = async (data:any) => {
  try {
      const response = await post<any>('/dailyPlan/update', data);
      return response;
  } catch (error) {
  }
};
// export function update(data:any) {
//   return request({
//     url: '/dailyPlan/update',
//     method: 'put',
//     data: data
//   })
// }

// 删除定时任务调度
export const delPlan = async (data:any) => {
  try {
      const response = await post<any>('/dailyPlan/delete', data);
      return response;
  } catch (error) {
  }
};

// 创建任务
export const createTask = async (data:any) => {
  try {
      const response = await post<any>('/dailyPlan/createTask', data);
      return response;
  } catch (error) {
  }
};


export interface DailyPlan {
  id: Number,
  userName: string,
  rememberStartDate: string,
  title: string,
  content: string,
  taskType: string,
  scheduledTaskDateTime: string,
  aheadMinutes: number,
  remark: string,
  createdTask: boolean,
}

export interface QueryParams {
  pageNum: number,
  pageSize: number,
  userId: number | null,
  rememberStartDate: string,
  title: string,
  taskType: string,
}

export interface DailyPlanAddRequest {
  userId: number | null,
  userName: string,
  rememberStartDate: string,
  title: string,
  content: string,
  taskType: number,
  scheduledTaskDateTime: string,
  aheadMinutes: number,
  remark: string,
  autoCreateTask: boolean,
}